package com.admin.service

import com.admin.dao.ThemeExamineDao
import com.data.annotation.NoargAnnotation
import com.data.annotation.OpenAnnotation
import com.data.bean.Theme
import com.data.bean.ThemeScreenshot
import com.data.util.CheckDataUtils
import com.data.util.DatabaseIdUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import java.awt.Image

@Service
@OpenAnnotation
@NoargAnnotation
class ThemeExamineService {
    @Autowired
    private var themeExamineDao: ThemeExamineDao? = null


    fun listExamineThemeService(): List<Theme> = this.themeExamineDao!!.listExamineThemeDao()

    fun passExamineThemeService(tid: String, state: String, content: String): Boolean {
        val bool = this.themeExamineDao!!.passExamineThemeDao(tid, state) > 0
        if (bool && state.toInt() == -1) {
            val s = if (content == "") {
                "请联系管理员询问原因"
            } else
                content
            this.themeExamineDao!!.nopassExamineThemeDao(tid, DatabaseIdUtils.dataIdOne, s) > 0
        }
        return bool
    }

    fun useThemeService(tid: String, state: String): Boolean = this.themeExamineDao!!.useThemeDao(tid, state) > 0

    fun listThemeService(): List<Theme> = this.themeExamineDao!!.listThemeDao()

    fun lookThemeService(tid: String): Theme? {

        if (CheckDataUtils.stringUtils(tid)) {
            return themeExamineDao!!.lookThemeDao(tid)
        }

        return null
    }

    fun deleteThemeService(id: String): Boolean = themeExamineDao!!.deleteThemeDao(id)

}